package indi.gao.redisTemplate;


import java.util.ArrayList;
import java.util.function.Consumer;

/**
 * <p>Description:</p>
 * <p>Copyright: Copyright (c)2019$</p>
 * <p>Company: Tope</p>
 * <P>Created Date :2019$-08$-12$</P>
 * <P>@version 1.0</P>
 */
class Person {
    private Long ID;

    public Long getID() {
        return ID;
    }

    public void setID(Long ID) {
        this.ID = ID;
    }

    @Override
    public String toString() {
        return "Person{" +
                "ID=" + ID +
                '}';
    }
}

public class Foreach {

    public static void main(String[] args) {
        ArrayList<Person> list = new ArrayList<>();
        Person person = new Person();
        person.setID(435L);
        Person person1 = new Person();
        person1.setID(465L);
        list.add(person);
        list.add(person1);
        list.forEach(System.out::println);
        list.forEach(new Consumer<Person>() {
            @Override
            public void accept(Person person) {
                System.out.println(person);
            }
        });
        list.forEach(x -> sop(x.getID()));
        list.forEach(person2 -> new Person().setID(person2.getID()));
        list.forEach(x -> {
            if (x.getID() == (435)) System.out.println("ok");
        });
    }

    private static void sop(Long s) {
        System.out.println(s);
    }
}
